package com.cmower.dzone.optional;

import java.util.Optional;
import java.util.function.Predicate;

/**
 * @author 沉默王二，一枚有趣的程序员
 */
public class OptionalMapFilterDemo {
    public static void main(String[] args) {
        String password = "password";
        Optional<String>  opt = Optional.ofNullable(password);

        Predicate<String> len6 = pwd -> pwd.length() > 6;
        Predicate<String> len8 = pwd -> pwd.length() < 10;
        Predicate<String> eq = pwd -> pwd.equals("password");

        boolean result = opt.map(String::trim).map(String::toLowerCase).filter(len6.and(len8).and(eq)).isPresent();
        System.out.println(result);
    }
}